<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<script src="/jquery/jquery-2.1.1.min.js"></script>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script>
        function dologin() {
            let username = $("#uname").val();
            let upsw = $("#upsw").val();
            if (username == null && username === ""){
                alert("账号不得为空")
            }
            if(upsw == null && upsw === ""){
              alert("密码不得为空")
            }
            $.ajax({
                url:"loginDo",
                type:"post",
                data:$("#loginForm").serialize(),
                success:function(data){
                    if (data.code) {
                        if(data.result==true){
                            location.href="list";
                        }else{
                            location.href="login";
                        }
                    } else {
                        alert("验证码错误请重新输入");
                    }

                }
            });
        }

    </script>
</head>
<body>
<h2>账号登录</h2>
<form class="form-signin" role="form" id="loginForm" onsubmit="return false">
账号：<input type="text"  name="uname" id="uname"/></br>
密码：<input type="password"  name="upsw" id="upsw"/></br>
<input type="text" name="code">
<img src="code">
<button onclick="dologin()">登录</button>
</form>
</body>
</html>